package cn.bdqn.service.impl;

import cn.bdqn.mapper.OrdersMapper;
import cn.bdqn.pojo.Orders;
import cn.bdqn.service.OrdersService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class OrdersServiceImpl implements OrdersService {
    @Resource
    OrdersMapper ordersMapper;

    @Override
    public IPage<Orders> getOrdersByPage(String custNo, Integer pageNo, Integer pageSize) {
        //组装分页条件
        Page<Orders> page=new Page<>(pageNo,pageSize);
        //组装查询条件
        QueryWrapper<Orders> qw=new QueryWrapper<>();
        qw.eq(custNo!=null&&!"".equals(custNo), "odr_customer",custNo);

        IPage<Orders> ordersIPage = ordersMapper.selectPage(page, qw);
        return ordersIPage;
    }
    @Override
    public Orders getOrders(Long id) {
        return ordersMapper.selectById(id);
    }

}
